package presenter;

import base.BasePresenter;
import base.ResultCallBack;
import bean.LunTanJiYanBean;
import bean.LunTanOffRecyBean;
import bean.LunTanSchoolTabBean;
import model.LunTanModel;
import view.LunTanView;

/**
 * Created by Windows on 2019/11/5.
 */

public class LunTanPresenter extends BasePresenter<LunTanView> {


    private LunTanModel lunTanModel;

    public LunTanPresenter() {
        this.lunTanModel = new LunTanModel();
        addModel(lunTanModel);
    }

    public void getData() {
        lunTanModel.getData(new ResultCallBack<LunTanSchoolTabBean>() {
            @Override
            public void onSuccess(LunTanSchoolTabBean lunTanSchoolTabBean) {
                if (mView!=null){
                    if (lunTanSchoolTabBean!=null){
                        mView.onSuccess(lunTanSchoolTabBean);
                    }
                }
            }

            @Override
            public void onFail(String error) {
                if (mView!=null){
                    mView.showToast(error);
                    mView.onFail(error);
                }
            }
        });
    }

    public void getOffData() {
        lunTanModel.getOffData(new ResultCallBack <LunTanOffRecyBean>() {
            @Override
            public void onSuccess(LunTanOffRecyBean lunTanOffRecyBean) {
                if (mView!=null){
                    if (lunTanOffRecyBean!=null){
                        mView.setOffSuccess(lunTanOffRecyBean);
                    }
                }
            }

            @Override
            public void onFail(String error) {
                mView.onFail(error);
            }
        });
    }

    public void getJiYanData() {
        lunTanModel.getJiYanData(new ResultCallBack <LunTanJiYanBean>() {
            @Override
            public void onSuccess(LunTanJiYanBean lunTanJiYanBean) {
                if (mView!=null){
                    if (lunTanJiYanBean!=null){
                        mView.setJiYanSuccess(lunTanJiYanBean);
                    }
                }
            }

            @Override
            public void onFail(String error) {
                    mView.onFail(error);
            }
        });
    }
}
